<?php

namespace app\common\validate;

use think\Validate;

/**
 * Created by PhpStorm.
 * User: yangxin
 * Date: 02/01/2017
 * Time: 12:59
 */
class SysUser extends Validate
{

    protected $rule = [
        ['name' , 'require|max:30','姓名不能为空|姓名不能超过30位'], // 验证规则和错误消息一起定义
        'username' => 'require|max:30',
        'password' => 'require|max:20|min:6',
        'phone' => 'require|number|max:11|min:11',
        'email' => 'require|email|max:30',
        'sex' => 'require',
        'status' => 'require',
        'remark' => 'max:255'
    ];

    protected $message = [
        //'name.require' => '姓名不能为空',
        //'name.max' => '姓名不能超过30位',
        'username.require' => '用户名不能为空',
        'username.max' => '用户名长度不能超过30位',
        'password.require' => '密码不能为空',
        'password.min' => '密码不能少于6位',
        'password.max' => '密码长度不能超过20位',
        'email.require' => '电子邮箱不能为空',
        'email.email' => '电子邮箱格式不正确',
        'email.max' => '邮箱长度不能超过30位',
        'phone.require' => '手机号不能为空',
        'phone.number' => '手机号只能是数字',
        'phone.max' => '手机号长度为11位',
        'phone.min' => '手机号长度为11位',
        'sex' => '性别不能为空',
        'status' => '状态不能为空',
        'remark' => '备注不能超过255位'
    ];

    protected $scene = [
        'edit' => ['name', 'username', 'phone', 'email', 'sex', 'status', 'remark']
    ];
}